package com.situ.day3;

import org.junit.Test;

public class ArrayDemo {
	
	@Test
	public void test1() {
		int num1 = 99;
		int num2 = 78;
		int num3 = 68;
		int[] array = new int[4];
		array[0] = 99;
		array[1] = 59;
		array[2] = 79;
		array[3] = 94;
		System.out.println(array[0]);
		System.out.println(array[2]);
		System.out.println("正序输出");
		for (int i = 0; i < array.length; i++) {
			System.out.println(array[i]);
		}
		System.out.println("逆序输出");
		for (int i = array.length - 1; i >= 0; i--) {
			System.out.println(array[i]);
		}
	}
	
	@Test
	public void test2() {
		int[] array = new int[4];
		array[0] = 99;
		array[1] = 59;
		array[2] = 79;
		array[3] = 94;
		int sum = 0;
		for (int i = 0; i < array.length; i++) {
			sum = sum + array[i];
		}
		System.out.println("成绩综合：" + sum);
	}
	
	// int[] score={0,0,1,2,3,5,4,5,2,8,7,6,9,5,4,8,3,1,0,2,4,8,7,9,5,2,1,2,3,9};
	@Test
	public void test4() {
		int[] score = {0,0,1,2,3,5,4,5,2,8,7,6,9,5,4,8,3,1,0,2,4,8,7,9,5,2,1,2,3,9};
		int[] countArray = new int[10];
		for (int i = 0; i < score.length; i++) {
			switch (score[i]) {
			case 0:
				countArray[0]++;
				break;
			case 1:
				countArray[1]++;
				break;
			case 2:
				countArray[2]++;
				break;
			case 3:
				countArray[3]++;
				break;
			case 4:
				countArray[4]++;
				break;
			case 5:
				countArray[5]++;
				break;
			case 6:
				countArray[6]++;
				break;
			case 7:
				countArray[7]++;
				break;
			case 8:
				countArray[8]++;
				break;
			case 9:
				countArray[9]++;
				break;
			default:
				break;
			}
		}
		//System.out.println("0出现次数：" + countArray[0]);
		//System.out.println("1出现次数：" + countArray[1]);
		//System.out.println("2出现次数：" + countArray[2]);
		for (int i = 0; i < countArray.length; i++) {
			System.out.println(i + "出现次数: " + countArray[i]);
		}
	}
	
	@Test
	public void test() {
	}
	
	
	
}
